<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>实验室员工</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
 </head>
 <body>
  <t:formvalid formid="formobj" dialog="true"  layout="table" tiptype="3" >
		<input id="id" name="id" type="hidden" value="${staff.id }">
		<input id="teacherNo" type="hidden" value="${staff.teacher.staffNo }"/>
		<table style="" cellpadding="0" cellspacing="1" class="formtable"> 
					
				<tr>
					<td align="right">
						<label class="Validform_label">
							工作人员:
						</label>
					</td>
					<td class="value"> 
                	     <input id="teacherId" name="teacherId" type="hidden"  value='${staff.teacher.id }'>               
					     <input id="realName"  type="text" style="width: 150px" class="inputxt" 
					      readonly="readonly" datatype="*" value='${staff.teacher.realName}'>
					     <t:choose hiddenName="teacherId" hiddenid="id" url="teacherController.do?goSelect" name="teacherList"
                          icon="icon-search" title="选择" textname="realName" isclear="false" isInit="true" fun='teacherSelected'></t:choose>
							
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">工作人员</label>
						
					</td>
					
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							任职文号:
						</label>
					</td>
					<td class="value">
					     <input id="positionNO" name="positionNO" type="text"  value="${staff.positionNO }"
					     	style="width: 250px" class="inputxt"   maxlength="30"  onkeypress="specialTextValidate()">
  					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							任职期限:
						</label>
					</td>
					<td class="value">
						<input id="startDate" value='<fmt:formatDate value="${staff.startDate }" pattern="yyyy-MM-dd"/>'  name="startDate" type="text" style="width: 100px" class="inputxt" >至
						<input id="endDate"  value='<fmt:formatDate value="${staff.endDate }" pattern="yyyy-MM-dd"/>' name="endDate" type="text" style="width: 100px" class="inputxt" > 	  
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							具体工作:
						</label>
					</td>
					<td class="value">
					     	 <textarea id="workDetail" onkeypress="specialTextValidate()"
					     	 name="workDetail" type="text" style="width: 250px;height:60px;" maxlength="255" class="inputxt" >${staff.workDetail}</textarea>
  					</td>
				</tr>
			</table>
		</t:formvalid>
		<script>
		function teacherSelected(iframe){
	 		var name =  iframe.getteacherListSelections("realName")[0];
	 		var number = iframe.getteacherListSelections("staffNo")[0];
	 		
	 		if(name.length > 0){
	 			$('#realName').val(name+"("+number+")");
	 			$('#teacherNo').val(number);
	 		} 
	 	}
		
		$(document).ready(function(){
			$("#startDate").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
			$("#endDate").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
			
			var id = $('#id').val();
			if(id.length < 10 && w.currentModStaff != undefined){ //修改未保存的信息，需要从内存中读取
				var staff = w.currentModStaff;
				var name = staff.teacherName;
				$('#realName').val(name);
				$('#id').val(staff.id);
				$('#startDate').val(staff.start);
				$('#endDate').val(staff.end);
				$('#teacherId').val(staff.teacherId);
				$('#workDetail').val(staff.workDetail);	
				$('#positionNO').val(staff.positionNO);
				$('#teacherNo').val(staff.teacherNo);
			}
		});
		
		//根据form表单内容，获取staff对象
		function getStaff(){
			var startDate = $('#startDate').val();
			var endDate = $('#endDate').val();
			var id = $('#id').val();
			var teacherId = $('#teacherId').val();
			var teacherNo = $('#teacherNo').val();
			var teacherName = $('#realName').val();
			var workDetail = $('#workDetail').val();
			var positionNO = $('#positionNO').val();
			
			if(endDate != '' && startDate !=''){
				if(startDate > endDate){
					tip('开始日期不能大于结束日期')
					return null;
				}
			}
			
			/* if(startDate ==''){
				tip('请选择任职期限的开始日期');
				return null;
			}*/
			
			var staff = {
					start:startDate,
					end:endDate,
					id:id,
					teacherId:teacherId,
					teacherName:teacherName,
					workDetail:workDetail,
					positionNO:positionNO,
					teacherNo:teacherNo
			}
		
			return staff;
		}
		</script>
 </body>
 